build(cmake): only allow to build as python extension - #152
Conversation
|
Docs preview: https://pr-152.monoprop-docs.pages.dev |
a3a3686 to
a8aa7c6
Compare
4e6f1e6 to
afd0488
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #152 +/- ##
==========================================
+ Coverage 87.61% 95.31% +7.69%
==========================================
Files 59 14 -45
Lines 4239 704 -3535
Branches 1497 88 -1409
==========================================
- Hits 3714 671 -3043
+ Misses 163 20 -143
+ Partials 362 13 -349
Flags with carried forward coverage won't be shown. Click here to find out more. |
ddc660a to
d9fd7a3
Compare
|
The PR is still in progress, it's not marked as draft as I need all CI jobs to run on each commit to check I'm not losing functionality. Sorry for the confusion! |
0485838 to
dad84db
Compare
|
this will also need to be merged by bypassing requirements, since the job names changed. Plus a change in required checks in the ruleset. |
|
This is now ready-ready to review |
There was a problem hiding this comment.
Pull request overview
This PR refactors the build/CI tooling to treat monoprop as a scikit-build-core–driven Python extension only, removing the remaining “standalone CMake project” pathways, and reshaping install + test/coverage flows around the editable build trees that uv sync creates.
Changes:
- Make top-level CMake configuration scikit-build-core–centric (with direct-CMake invocation discouraged) and gate C++ unit tests behind a dedicated option.
- Rework CMake install and header handling to use
target_sources(FILE_SET ...), installing artifacts under the Python package layout. - Simplify developer/CI workflows (presets, VS Code tasks, just recipes, GitHub Actions) to build/test via the scikit-build-core editable trees and consolidate coverage.
Reviewed changes
Copilot reviewed 27 out of 28 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
uv.lock |
Removes gcovr and its transitive lock entries from the locked environment. |
pyproject.toml |
Drops gcovr from dev deps; updates cibuildwheel env to explicitly disable C++ unit tests during wheel builds. |
CMakeLists.txt |
Moves to scikit-build-core–first configuration, adds monoprop_ENABLE_CXX_UNIT_TESTS, and gates tests/cpp accordingly. |
src/CMakeLists.txt |
Updates CMake package config install location and version-file generation for the new install layout. |
src/monoprop/CMakeLists.txt |
Switches to FILE_SET-based header installation, adjusts install destinations under the Python package, and reorganizes subdirectories. |
src/monoprop/bindings/CMakeLists.txt |
Removes local Python discovery, updates compile flag handling, and rewrites RPATH logic for the new package layout. |
src/monoprop/algebra/CMakeLists.txt |
Adds explicit header listing via FILE_SET. |
src/monoprop/core/CMakeLists.txt |
Adds explicit header listing via FILE_SET. |
src/monoprop/detail/CMakeLists.txt |
Adds explicit header listing via FILE_SET and enumerates detail subdirectories. |
src/monoprop/detail/evolution/CMakeLists.txt |
Adds explicit header listing via FILE_SET and includes layer_build. |
src/monoprop/detail/evolution/layer_build/CMakeLists.txt |
Adds explicit header listing via FILE_SET. |
src/monoprop/detail/graph/CMakeLists.txt |
Adds explicit header listing via FILE_SET. |
src/monoprop/detail/graph_encoding/CMakeLists.txt |
Adds explicit header listing via FILE_SET. |
src/monoprop/detail/monomial_propagator/CMakeLists.txt |
Adds explicit header listing via FILE_SET. |
src/monoprop/detail/mpi/CMakeLists.txt |
Adds explicit header listing via FILE_SET. |
src/monoprop/detail/operator/CMakeLists.txt |
Adds explicit header listing via FILE_SET. |
src/monoprop/detail/pare/CMakeLists.txt |
Adds explicit header listing and adds PareGraph.cpp as a private source. |
src/monoprop/detail/partition/CMakeLists.txt |
Adds explicit header listing via FILE_SET. |
tests/cpp/CMakeLists.txt |
Ensures CPM is included and configures msgpack-cxx via CPM for the C++ test suite. |
tests/cpp/boostAddTests.cmake |
Labels C++ tests with cxx for CTest filtering/reporting. |
justfile |
Consolidates test recipes and reworks the coverage flow to run via scikit-build-core editable trees. |
CMakePresets.json |
Replaces standalone configure/build/test presets with “adopt existing skbuild tree” presets. |
.vscode/tasks.json |
Switches VS Code tasks to uv sync-based install modes (Release/Debug/Coverage). |
.vscode/settings.json |
Disables CMake Tools auto-reconfigure and enables CTest Explorer integration for adopted build trees. |
.github/workflows/test.yml |
Overhauls CI into package-centric matrix runs, adds find_package(monoprop) smoke test, runs C++ unit tests via ctest, and consolidates coverage jobs. |
.github/workflows/docpages.yml |
Sets env to disable C++ unit tests for docs builds. |
.github/workflows/copilot-setup-steps.yml |
Sets CPM_USE_LOCAL_PACKAGES and updates uv sync invocation for setup. |
.devcontainer/postStartCommand.sh |
Makes prek install overwrite existing hooks in the devcontainer. |
ae25e7c to
2587fab
Compare
Thus avoiding a rebuild when invoking pytest
Fallout from removing most of the cmake presets
Needs lcov format, plus some workarounds, to merge the Python and C++ results.
88dfbf7 to
72965c2
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 28 out of 29 changed files in this pull request and generated 1 comment.
Suppressed comments (8)
.github/workflows/test.yml:209
- The job expects a scikit-build-core Coverage build tree (
build/editable/Coverage) later (gcovr + ctest), but the install step runsuv syncwithout selecting Coverage build type. Unless an undocumented env var happens to be honored,build/editable/Coveragewon’t exist and the subsequent steps will fail.
- name: Install package
run: |
uv sync --no-progress --group test --all-extras -v
.github/workflows/test.yml:266
SKBUILD_CMAKE_DEFINEis not the documented mechanism for passing CMake definitions to scikit-build-core in this repo; useSKBUILD_CMAKE_ARGS(or pass--config-settings=cmake.define...touv sync) so MPI is reliably enabled for Sonar’s compilation database.
env:
SKBUILD_CMAKE_DEFINE: "monoprop_ENABLE_MPI=ON"
.github/workflows/test.yml:176
- Codecov’s
files:input is typically parsed as a comma-separated list; the second entry here has a leading space, which can be interpreted as part of the filename and cause the ctest report upload to be skipped.
- name: Upload test results to Codecov
uses: codecov/codecov-action@v7.0.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: pytest-${{ steps.test-group-label.outputs.label }}.xml, ctest-${{ steps.test-group-label.outputs.label }}.xml
report_type: test_results
CMakeLists.txt:8
- This project now relies on scikit-build-core-only configuration, but the current direct-CMake path only emits a warning and then continues into SKBUILD-specific code paths (which can fail later with less actionable errors). If direct CMake invocation is intentionally unsupported, prefer failing fast here.
if(NOT SKBUILD)
message(
WARNING
"\
.github/workflows/test.yml:60
SKBUILD_CMAKE_DEFINEis not the documented knob for scikit-build-core in this repo (docs useSKBUILD_CMAKE_ARGS/--config-settings=cmake.define...). If this env var is ignored, the matrix ‘wide term index’ build won’t actually be wide.
This issue also appears in the following locations of the same file:
- line 171
- line 206
- line 265
env:
SKBUILD_CMAKE_DEFINE: "monoprop_WIDE_TERM_INDEX=${{ matrix.wide }}"
.github/workflows/docpages.yml:44
SKBUILD_CMAKE_DEFINEis not the documented knob for scikit-build-core in this repo. If it’s ignored, the docs build will still compile the C++ unit tests even though this workflow intends to disable them.
env:
SKBUILD_CMAKE_DEFINE: monoprop_ENABLE_CXX_UNIT_TESTS=OFF
justfile:49
- The repo docs still reference the old Just recipes (
test-py,test-py-mpi,test-py-mpi-matrix) that were removed/renamed here (seedocs/content/docs/testing.mdx:18,26-27). This makes the documented test commands incorrect after this change.
test:
uv run python -m pytest -m "not mpi"
ctest --test-dir build/editable/Release --output-on-failure
# MPI is off by default in source builds, so build an MPI-enabled editable install
# first, then run the suite under mpiexec with --no-sync (avoids a per-rank resync).
# Pass RANKS as either a single integer or a semicolon-separated list (e.g. "1;2;4").
test-mpi RANKS='':
export OMPI_MCA_rmaps_base_oversubscribe="1"
uv sync --all-extras --group test --reinstall-package monoprop --no-cache --config-settings-package="monoprop:cmake.define.monoprop_ENABLE_MPI=ON" -v
ranks="${1:-${monoprop_MPI_TEST_PROCS:-2}}"
for r in ${ranks//;/ }; \
do echo "Running full Python test suite with ${r} MPI rank(s)"; \
mpiexec -n "$r" uv run --no-sync python -m pytest tests --with-mpi -v; \
echo "Running C++ unit tests with ${r} MPI rank(s)"; \
ctest --test-dir build/editable/Release --output-on-failure \
done
CMakeLists.txt:32
include/monoprop/Info.his generated frominclude/monoprop/Info.h.in, but the placeholders@PROJECT_VERSION_FULL@and@GIT_COMMIT@are no longer defined anywhere in CMake (DynamicVersion was removed). As a result,monoprop::version()andmonoprop::git_commit()will expand to empty strings in the built artifact.
endif()
if(APPLE)
Signed-off-by: Roberto Di Remigio Eikås <robertodr@users.noreply.github.com>
|
Comments to address from Copilot: justfile:49
CMakeLists.txt:32
|
They were only needed when building as a standalone C++ project. The same information can now be obtained from the Python layer.
|



By opening this PR I confirm that I have read CONTRIBUTING.md and I agree to the terms of the Contributor License Agreement.
Summary
This project is purely a Python extension but the build system, and configuration around it, still offered the (vestigial) option of building as a C++-only project.
Re-hash of #106, where I made a hideous mistake with the git history.
Fixes #136
Changes
Remove CMake code that allowed to build as a standalone C++ project, as that is no longer meaningful. A warning is issued against compiling with direct invocation to CMake.
C++ unit tests are gated behind a new CMake option
monoprop_ENABLE_CXX_UNIT_TESTS, which is ON by default.CMakePresets.jsonchanged accordingly, as it's effectively only needed for test autodiscovery.Edit
justfileto account for loss of many presets for CMake.Overhaul CMake code for installation of artifacts. The package is installed under
lib/python3.X/site-packages/monopropall other artifacts are installed in subfolders of it:libmonoprop.sois underlib(orlib64, depending on the machine)includewith the proper hierarchical folder structurecmakeThe header files are now explicitly listed (instead of globbed) and we usetarget_sourceswithFILE_SETpento handle them sanely (instead of appending to a global list)I have dropped the distinction between private and public for now.
Simplified
test.ymlaccordingly:Checklist
docs/,CONTRIBUTING.md) if neededCHANGELOG/ release notes updated if applicableAI/LLM disclosure
This is part 1 of 3 in a stack made with GitButler: